package org.jsola.hr.helper;

import org.jsola.common.SafeKit;
import org.jsola.hr.dto.TransferAccountsVxDetailAddDTO;
import org.jsola.hr.dto.TransferAccountsVxDetailUpdateDTO;
import org.jsola.hr.entity.TransferAccountsVxDetailDO;
import org.jsola.hr.query.TransferAccountsVxDetailQuery;
import org.jsola.hr.service.ITransferAccountsVxDetailService;
import org.jsola.hr.vo.TransferAccountsVxDetailVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.List;

import static org.jsola.hr.core.AbstractTest.SITE_ID;



/**
 * 转账明细(微信)
 *
 * @author zhr
 */
@Component
public class TransferAccountsVxDetailTestHelper extends BaseTestHelper {
    
    @Autowired
    private ITransferAccountsVxDetailService transferAccountsVxDetailService;

    /**
     * 生成add测试数据
     * @return TransferAccountsVxDetailAddDTO
     */
    public TransferAccountsVxDetailAddDTO getTransferAccountsVxDetailAddDTO(){
        TransferAccountsVxDetailAddDTO transferAccountsVxDetailAddDTO = new TransferAccountsVxDetailAddDTO();
        transferAccountsVxDetailAddDTO.setSpMchid(getRandomValue("varchar",32));
        transferAccountsVxDetailAddDTO.setBatchId(getRandomValue("varchar",100));
        transferAccountsVxDetailAddDTO.setVxBatchId(getRandomValue("varchar",32));
        transferAccountsVxDetailAddDTO.setAppid(getRandomValue("varchar",32));
        transferAccountsVxDetailAddDTO.setDetailId(getRandomValue("varchar",64));
        transferAccountsVxDetailAddDTO.setDetailStatus(getRandomValue("varchar",32));
        transferAccountsVxDetailAddDTO.setTransferAmount(SafeKit.getInteger(getRandomValue("int",20)));
        transferAccountsVxDetailAddDTO.setTransferRemark(getRandomValue("varchar",32));
        transferAccountsVxDetailAddDTO.setFailReason(getRandomValue("varchar",64));
        transferAccountsVxDetailAddDTO.setOpenid(getRandomValue("varchar",64));
        transferAccountsVxDetailAddDTO.setUsername(getRandomValue("varchar",1024));
        transferAccountsVxDetailAddDTO.setInitiateTime(getRandomValue("varchar",32));
        transferAccountsVxDetailAddDTO.setUpdateTime(getRandomValue("varchar",32));
        return transferAccountsVxDetailAddDTO;
    }


    /**
     * 生成update测试数据
     * @return TransferAccountsVxDetailUpdateDTO
     */
    public TransferAccountsVxDetailUpdateDTO getTransferAccountsVxDetailUpdateDTO(TransferAccountsVxDetailVO transferAccountsVxDetailVO){
        return transferAccountsVxDetailService.selectDOById(transferAccountsVxDetailVO.getId(), SITE_ID).to(TransferAccountsVxDetailUpdateDTO.class);
    }

    /**
     * 生成查询数据
     * @return TransferAccountsVxDetailQuery
     */
    public TransferAccountsVxDetailQuery getTransferAccountsVxDetailQuery() {
        TransferAccountsVxDetailQuery transferAccountsVxDetailQuery = new TransferAccountsVxDetailQuery();
        List<TransferAccountsVxDetailDO> transferAccountsVxDetailDOList = transferAccountsVxDetailService.list(new TransferAccountsVxDetailDO(),SITE_ID);
        if (!CollectionUtils.isEmpty(transferAccountsVxDetailDOList)) {
            TransferAccountsVxDetailDO transferAccountsVxDetailDO = transferAccountsVxDetailDOList.get(0);
            transferAccountsVxDetailQuery = transferAccountsVxDetailDO.to(TransferAccountsVxDetailQuery.class);
        }
        return transferAccountsVxDetailQuery;
    }

    /**
     * 保存示例
     * @return TransferAccountsVxDetailVO
     */
    public TransferAccountsVxDetailVO saveTransferAccountsVxDetailExample(){
        TransferAccountsVxDetailAddDTO addDTO = this.getTransferAccountsVxDetailAddDTO();
        TransferAccountsVxDetailVO transferAccountsVxDetailVO = transferAccountsVxDetailService.save(addDTO,buildTokenUser());
        return transferAccountsVxDetailVO;
    }


}

